﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Vehicle.Web.Pages.Role
{
    /// <summary>
    /// Copyright (C) M-Tear团队
    /// 文 件 名：Role_ADD.aspx.cs
    /// 版    本：v1.00.0000
    /// 创建标识：2009-08-27   Created by 杨光远 V1.00.0000
    /// 功能说明：角色添加页面
    /// 注意事项：无
    /// 
    /// 更新记录：
    /// 
    /// </summary>
    public partial class Role_Add : Vehicle.Web.Component.PageBase
    {
        #region---基本变量的实例化---
        BLL.Role b_Role = new BLL.Role();
        BLL.Log b_Log = new Vehicle.BLL.Log();
        #endregion

        #region---基本操作---
        /// <summary>
        /// 页面加载事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {

            }
        }
        protected void Btn_Go_Click(object sender, EventArgs e)
        {
            //添加判断是否有相同的角色
            if (b_Role.GetModel(new Vehicle.Model.ComponentsInfo("Role", "R_Name", this.Txt_R_Name.Text.Trim(), "R_ID")).Rows.Count == 0)
            {
                b_Role.Add(new Model.RoleInfo(Txt_R_Name.Text.Trim(), Vehicle.Common.TextHelper.CheckStr(Txt_R_Note.Text).Trim()));//添加角色
                b_Log.Add(new Vehicle.Model.LogInfo(session_ID, DateTime.Now, "成功添加角色（" +Txt_R_Name.Text.Trim() + "）"));//添加日志
                Vehicle.Common.MessageHelper.AlertRedirect("添加角色成功", "Main.aspx");
            }
            else
            {
               Vehicle.Common.MessageHelper.Alert("系统已经存在相同的角色,请重新填写");
            }
        }
        #endregion
    }
}
